#!/usr/bin/python 
# -*- coding=utf-8 -*-

import time
import os

class IDGenerator():
    def __init__(self):
        self.counter = 0

    def getID(self):
        self.counter += 1
        if self.counter >= (1 << 16):
            self.counter = 0
        id = int(time.time())
        id = (id << 16) | int(os.getpid())
        id = (id << 16) | self.counter
        return id
        
if __name__ == '__main__':
    idg = IDGenerator()
    print idg.getID()
    print idg.getID()

